Skip to content

Implement SetClock Function #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2025
Merged

Conversation

mjs513
Copy link

@mjs513 mjs513 commented Jan 8, 2025

Implemented I2C setClock funtion.

void arduino::ZephyrI2C::setClock(uint32_t freq) {
    uint8_t speed = 	I2C_SPEED_STANDARD;
	if(freq >  0x06u ) {
		if(freq == 100000) {
		  speed = I2C_SPEED_STANDARD;
		} else if(freq == 400000) {
		  speed = I2C_SPEED_FAST;
		} else if(freq == 1000000) {
		  speed = I2C_SPEED_FAST_PLUS;
		} else {
		  speed = I2C_SPEED_STANDARD;
		}
	} else {
		speed = (uint8_t) freq;
	}
	uint32_t i2c_cfg = I2C_MODE_CONTROLLER |
					I2C_SPEED_SET(speed);

	if (i2c_configure(i2c_dev, i2c_cfg)) {
		//Serial.println("Failed to configure i2c interface.");
	}
}

frequency can be 100000, 400000 or I2C_SPEED_STANDARD or I2C_SPEED_FAST, while I2C_SPEED_FAST_PLUS is there (like in mbed) does not seem to register right now so only 100khz and 400khz are supported.

See #23 (comment)

@facchinm facchinm merged commit 8514e6e into arduino:arduino Jan 9, 2025
1 of 3 checks passed
@mjs513 mjs513 deleted the I2C-SetClock branch January 11, 2025 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants